<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  	<!-- 布置作业板块 -->
    <base href="<%=basePath%>">
    <title>布置作业</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1" />
	<script src="js/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=path %>/css/f/default.css"/>
	<link rel="stylesheet" type="text/css" href="<%=path %>/css/f/navs.css"/>
	<link rel="stylesheet" type="text/css" href="<%=path %>/css/f/assignment.css"/>
	<script type="text/javascript" src="js/f/jskey_calendar.js"></script>
	<script src="js/f/default.js"></script>
</head>

<body>
	<div class="all">
		<jsp:include page="/nav.jsp"></jsp:include>
        <div class="rightall float-left">
            <div class="arrangement">
            <input type="hidden" value="${error_msg }" name="errorMsg" />
                <div class="form" style="margin-top:10px;">
                    <form method="post" name="arrangement" enctype="multipart/form-data" action="teacher/assignment.do">
                    	<div class="a-width float-left">
                    		<div style="width:100%;">
                                <div>作业提交截止时间</div>
                                <input type="text" onclick="$jskey.calendar.show(this, {min:'2018-05-31 09:10:11',max:'3000-03-25 09:10:11',lang:0,format:'yyyy-MM-dd HH:mm',show:'yyyy-MM-dd HH:mm'})"
                                 value="" name="homeworkDeadline" class="query"/>
                    		</div>
                            <div class="float-left" style="width:100%; margin-top:55px;">
                                <div>班级</div>
                                <select class="query" name="className">
                                <c:forEach var="s" items="${cour}">
                                    <option value="${s.className }">${s.className }</option>
                                </c:forEach>
                                </select>
                            </div> 
                        </div>
                    	<div class="float-left margin-left" style="width:35%;">
                            <div>作业内容</div>
                            <textarea class="content" name="homeworkContent" ></textarea>
                        </div>
                        <div class="float-left margin-left b-width">
                        	<div>作业内容文件</div>
                            <input type="text" name="homeworkFile" id="fileup" class="float-left" />
                            <label class="upload float-left btn-style">选择文件
                                <input type="file" class="xfile" name="uploadFile" onchange="document.getElementById('fileup').value=this.value"/>
                            </label>
                            <button class="submit btn-style" type="submit" style="margin-top:75px;">发布作业</button>
                        </div>
                    </form>
                </div>
            </div>
  			<div class="already">
  				<div class="already-title">
  					<div class="left">历史布置作业</div>
  				</div>
                <div>
                	<form method="post" action="teacher/releaseWork.do">
                		<div style="margin-top: 15px;">
                			<span style=" margin-left:30%;"></span>
                			班级:<select class="task" name="className">
                                <c:forEach var="s" items="${cour}">
                                    <option value="${s.className }">${s.className }</option>
                                </c:forEach>
                                </select>
                			<span style=" margin-left:50px;"></span>
                			<input class="task btn-style" type="submit" value="查找">
                		</div>
                	</form>
                    <table>
                        <tr class="tr-style-head">
                            <td class="z-width">班级</td>
                            <td class="t-width">发布时间</td>
                            <td class="t-width">提交截止时间</td>
                            <td class="y-width">已交</td>
                            <td class="y-width">合格</td>
                            <td class="z-width">提交状态</td>
                            <td class="c-width">操作</td>
                        </tr>
                        <c:forEach var="s" items="${hws }">
	                        <tr class="tr-style">
	                            <td>${s.className }</td>
	                            <td><fmt:formatDate value="${s.createTime}" pattern="yyyy-MM-dd hh:mm"/></td>
	                            <td><fmt:formatDate value="${s.homeworkDeadline}" pattern="yyyy-MM-dd hh:mm"/></td>
	                            <td>${s.countWork }</td>
	                            <td>${s.countScore }</td>
	                            <td>
	                            	<c:if test="${s.submitState==2 }">
	                            		<span class="span-color-red">中止提交</span>
	                            	</c:if>
	                            	<c:if test="${s.submitState==1 }">
	                            		<span class="span-color-blue">提交中</span>
	                            	</c:if>
	                            </td>
	                            <td><a class="a-color-red" href="teacher/delete.do?homeworkId=${s.homeworkId }" onclick="Delete()">删除</a>/
	                                <a href="teacher/correting.do?homeworkId=${s.homeworkId }" class="a-color-red">批改</a>
	                            </td>
	                        </tr>
                      	</c:forEach>
                    </table>
                </div>
	            <c:if test="${pages > 1 }">
               		<div class="previous">
	               		<c:if test="${pageNo>1}">
	                    	<a href="teacher/releaseWork.do?pageNo=${pageNo-1}">上一页</a>
	                	</c:if>
	                   	<c:forEach var="p" begin="1" end="${pages }" step="1">
	                   		<c:if test="${p==pageNo }">
	                   			<span style="font-size:18px;color:#446ee6;">&nbsp;${p}&nbsp;</span>
	                   		</c:if>
	                   		<c:if test="${p!=pageNo }">
	                   			<a href="teacher/releaseWork.do?pageNo=${p }" >&nbsp;${p}&nbsp;</a>
	                   		</c:if>
	                   	</c:forEach>
	                    <c:if test="${pageNo<pages}">
	                    	<a href="teacher/releaseWork.do?pageNo=${pageNo+1}">下一页</a>
	                	</c:if>
                   </div>
                </c:if>
            </div>
        </div>
    </div>
</body>
	<script type="text/javascript">
		//删除验证
		function Delete(){
			var r=window.confirm("确认删除？");
			if (r==true){
				return true;
			}else{
				return false;
			}
		}
		//发布作业表单验证
		var eles = document.arrangement.elements;
		var date=eles.deadline;
		var content=eles.content;
		var contentFile=eles.file;
		document.arrangement.onsubmit=function(){
			if(date.value==""){
				alert("没有填写日期!");
				return false;
			}
			if(content.value=="" && contentFile.value==""){
				alert("作业内容与内容文件必须填写其中一个!");
				return false;
			}
			return true;
		}
	</script>
</html>
